package ai.tasks;

import ai.AIConstant;
import ai.Trackable;
import ai.engine.AICity;
import ai.engine.AIResource;
import ai.engine.Task;
import ai.engine.TaskDoer;
import ai.engine.factories.TaskFactory;
import engine.CityAction;
import engine.GameEngine;
import engine.data.Unit;
import util.List;

public class BuildUnitTask extends Task {

	private boolean isObjectiveAchieved;

	public BuildUnitTask(short id, Trackable target) {
		super(id, TaskFactory.BUILD_UNIT_TASK, AICity.class, "Build Unit", "",
				AIConstant.PRIORITY_STRONG, target, (byte) 1, (byte) 1);
		isObjectiveAchieved = false;
	}

	public AIResource getTarget() {
		return (AIResource) target;
	}

	public AICity getTaskDoer() {
		return (AICity) this.assignedResources.get(0);
	}

	public boolean isTaskSuitable(TaskDoer possibleTaskDoer) {
		//AICity possibleCityDoer = (AICity) possibleTaskDoer;
		return true;
	}

	public short getFormula(TaskDoer possibleTaskDoer) {
		//AICity possibleCityDoer = (AICity) possibleTaskDoer;
		return (short) (this.priority);
	}

	public byte getAction(TaskDoer taskDoer) {
		CityAction cityAction = new CityAction(getTaskDoer(), Unit.class, getTarget().unitType);
		GameEngine.doCityAction(cityAction);
		return 1;
	}

	public List getAdditionalResourcesNeeded() {
		return null;
	}
	
	public boolean isObjectiveAchieved() {
		return isObjectiveAchieved;
	}

}
